<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en" class="no-js" id="ng-app">
<head>
<meta charset="UTF-8">
<jsp:include page="/includes/common/head.jsp" />
<title>CS4280 BOOKSTORE</title>
</head>
<body>
	<div data-flex-background-src="${ baseURL }/assets/img/background.jpg"
		flex-background></div>
	<jsp:include page="/includes/header.jsp">
		<jsp:param name="currentUser" value="${currentUser}" /><jsp:param name="baseURL" value="${ baseURL }" />
		
	</jsp:include>
	<section id="mainContent">
		<c:if test="${action == null || action == 'new'}">
			<form method="POST" action="${ baseURL }/admin/manage/member?action=new">
				<ul>
					<li><label>Username: </label> <input type="text"
						name="username" required="required" /></li>
					<li><label>Password: </label> <input type="password"
						name="password" required="required" /></li>
					<li><label>Repeat Password: </label> <input type="password"
						name="password_repeat" required="required" /></li>
					<li><label>Salt: </label> <input type="text"
						name="salt" required="required" value="" /></li>
					<li><label>Email: </label><input type="text" name="email"
						required="required" /></li>
					<li><label>Telephone No: </label><input type="text" name="telephone"
						required="required" /></li>
					<li><label>Role: </label>
						<select name="role">
							<option value="ROLE_ADMIN">Admin</option>
							<option value="ROLE_USER">Member</option>
						</select>
					</li>
					<li><label>Loyalty Point: </label><input type="text" name="loyaltyPoint"
						required="required" /></li>
				</ul>
				<input type="submit" value="Register" />
				<input type="hidden" name="submit" value="true" />
			</form>
		</c:if>

		<c:if test="${action == 'failed'}">
			<form method="POST" action="${ baseURL }/admin/manage/member?action=new">
				<c:if test="${isTelephoneNotInt}">
					<span class="form-error">Telephone is used not a integer. Please
						try again.</span><br />
				</c:if>
				<c:if test="${isLoyaltyPointNotInt}">
					<span class="form-error">Loyalty Point is used not a integer. Please
						try again.</span><br />
				</c:if>
				
				<ul>
					<li><label>Username: </label> <input type="text" name="username"
						required="required" value="${ user.username }" /></li>
					<li><label>Password: </label> <input type="password"
						name="password" required="required" value="" /></li>
					<li><label>Password: </label> <input type="password"
						name="password_repeat" required="required" value="" /></li>
					<li><label>Salt: </label> <input type="text"
						name="salt" required="required"  value="${ user.salt }" /></li>
					<li><label>Email: </label><input type="text" name="email"
						required="required" value="${ user.email }" /></li>
					<li><label>Telephone No: </label><input type="text" name="telephone"
						required="required" value="${ user.telephone }" /></li>
					<li><label>Role: </label>
						<select name="role" required="required">
							<option value="ROLE_ADMIN">Admin</option>
							<option value="ROLE_USER">Member</option>
						</select>
					</li>
					<li><label>Loyalty Point: </label><input type="text" name="loyaltyPoint"
						required="required" /></li>
				</ul>
				<input type="submit" value="Register" />
				<input type="hidden" name="submit" value="true" />
			</form>
		</c:if>
	</section>
</body>
</html>